package com.neu.wangweili.servlet;

import com.neu.wangweili.service.W_SendMsgService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "W_SendMsgServlet", urlPatterns = {"/W_SendMsgServlet"})
public class W_SendMsgServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String tel=request.getParameter("tel");
        response.setCharacterEncoding("UTF-8");
        W_SendMsgService w_sendMsgService=new W_SendMsgService();
        String text=w_sendMsgService.sendMsg(tel);
        System.out.println(text);
            text="{\"text\":\""+text+"\"}";


        PrintWriter out=response.getWriter();
        out.write(text);
        out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
